﻿<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">修改房源</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">房源</a>
                </li>
                <li class="breadcrumb-item active">修改房源</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">修改房源信息</h3> 
                </div>
                <div class="panel-body">
                    <div class="example-wrap">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="panel-body container-fluid">
                                    <div class="row row-lg">

                                        <div class="col-sm-6 col-md-6">
                                            <div class="example-wrap margin-sm-0" id="div_yuanliaomingcheng">
                                                <h4 class="example-title">所属小区</h4>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" readonly="readonly" id="danxiaoqu" placeholder="所需数量，请填数字" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 col-md-6">
                                            <div class="example-wrap margin-sm-0" id="div_suoxushuliang">
                                                <h4 class="example-title">楼号</h4>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" readonly="readonly" id="louhao" placeholder="所需数量，请填数字" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 col-md-6">
                                            <div class="example-wrap margin-sm-0" id="div_suoxushuliang">
                                                <h4 class="example-title">层</h4>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" readonly="readonly" id="cheng" placeholder="所需数量，请填数字" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 col-md-6">
                                            <div class="example-wrap margin-sm-0" id="div_suoxushuliang">
                                                <h4 class="example-title">门</h4>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" readonly="readonly" id="men" placeholder="所需数量，请填数字" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6 col-md-12">
                                            <div class="example-wrap margin-sm-0" id="div_suoxushuliang">
                                                <h4 class="example-title">状态</h4>
                                                <div class="form-group">
                                                    <select class="form-control" id="zhuangtai">
                                                        <option value="已出售">已出售</option>
                                                        <option value="未出售">未出售</option>
                                                        <option value="审核中">审核中</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-12 col-md-12">
                                            <div class="example-wrap margin-sm-0">
                                                <h4 class="example-title"></h4>
                                                <div class="form-group" style="margin-top: 28px;">
                                                    <button type="button" class="btn btn-block btn-info" id="btn_tianjia" onclick="XuGai();">修改</button>
                                                </div>
                                            </div>
                                            <div class="example-wrap margin-sm-0">
                                                <h4 class="example-title"></h4>
                                                <div class="form-group" style="margin-top: 28px;">
                                                    <button type="button" class="btn btn-block btn-info" id="btn_tianjia" onclick="ShanChu();">删除</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <input type="text" hidden="hidden" id="fangyuanid" />
        <input type="text" hidden="hidden" id="xiaoquidzhi" />
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#SpanFangWu").click();
        var shu = getQuery("fangyuan");
        $("#fangyuanid").val(shu);
        shuju();
    });

    function shuju() {
        var id = $("#fangyuanid").val();
        $.ajax({
            type: 'post',
            url: '../FangYuanXinXi/GetShuJuXinXi',
            async: false,
            dataType: 'json',
            data: {id:id},
            success: function (date) {
                $(date).each(function (key) {
                    $("#danxiaoqu").val(date[key].danxiaoqu);
                    $("#louhao").val(date[key].louhao);
                    $("#cheng").val(date[key].cheng);
                    $("#men").val(date[key].men);
                    $("#zhuangtai").val(date[key].zhuangtai);
                    $("#xiaoquidzhi").val(date[key].xiaoquidzhi);
                })
            },
        })
    }


    function XuGai() {
        var xiaoqu = $("#xiaoquidzhi").val();
        var louhao = $("#louhao").val();
        var cheng = $("#cheng").val();

        var id = $("#fangyuanid").val();
        var zhuangtai = jQuery("#zhuangtai").val();
        $.ajax({
            type: 'post',
            url: '../FangYuanXinXi/XuGai',
            dataType: 'text',
            async: true,
            data: { zhuangtai: zhuangtai, id: id},
            success: function (result) {
                if (result == "1") {
                    alert("修改成功");
                    location.href = "../FangYuanXinXi/FangYuanXinXiList?xiaoqu=" + xiaoqu + "&louhao=" + louhao + "&ceng=" + cheng;
                } else{
                    alert("修改失败");
            }
            }
        });
    }

    function ShanChu() {
        var id = $("#fangyuanid").val();
        var xiaoqu = $("#xiaoquidzhi").val();
        var louhao = $("#louhao").val();
        var cheng = $("#cheng").val();
        $.ajax({
            type: 'post',
            url: '../FangYuanXinXi/ShanChu',
            dataType: 'text',
            async: true,
            data: {id: id },
            success: function (result) {
                if (result == "1") {
                    alert("删除成功");
                    location.href = "../FangYuanXinXi/FangYuanXinXiList?xiaoqu=" + xiaoqu + "&louhao=" + louhao + "&ceng=" + cheng;
                } else {
                    alert("删除失败");
                }
            }
        });
    }

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }


</script>